// sizeof

#include <iostream>
#include <iomanip>
using namespace std;

int main() {
    // sizeof用于类型
    cout.setf(ios::right);
    cout << "以下数据类型占用的字节数\n";
    cout << setw(10) << "char = " << sizeof(char) << "\n";
    cout << setw(10) << "int = " << sizeof(int) << "\n";
    cout << setw(10) << "long = " << sizeof(long) << "\n";
    cout << setw(10) << "float = " << sizeof(float) << "\n";
    cout << setw(10) << "double = " << sizeof(double) << "\n";

    // sizeof用于变量
    char c;
    int i;
    long l;
    float f;
    double d;

    cout << "\n以下数据类型的变量占用的字节数\n";
    cout << setw(10) << "char = " << sizeof(c) << "\n";
    cout << setw(10) << "int = " << sizeof(i) << "\n";
    cout << setw(10) << "long = " << sizeof(l) << "\n";
    cout << setw(10) << "float = " << sizeof(f) << "\n";
    cout << setw(10) << "double = " << sizeof(d) << "\n";
}